<?php
/**
 *   @package
 *   @copyright   Copyright (C) 2005 - 2010 Cristian Sfercoci. All rights reserved.
 *   @since     03.05.2012
 *   @user      Kristian
 */


class guestInAction extends sfAction {
	public function execute($request) {
		$id = $request->getParameter('id');
		$current_state = $request->getParameter('current');
		
		//toggle action
		if ($current_state=="1"){
			$current_state="0";
		}else{
			$current_state=1;
		}
		SqlEngineCore::get()->update(
		array('table' => 'reservation',
                          'columns' => array(
                                'guest_in' => $current_state),
                          'where' => array(
                                'reservation_id' => $id)));

		$reservation = SqlEngine::getReservations(array('reservation_id' => $id));
		return $this->renderText(json_encode(array("guest_in"=>$reservation[0]['guest_in'])));
	}
}
?>